package controllers

import (
	"net/http"

	"github.com/gin-gonic/gin"
)

// json返回的数据结构
type JsonStruct struct {
	Code  int         `json:"code"`
	Data  interface{} `json:"data"`
	Count int64       `json:"count"`
	Msg   interface{} `json:"msg"`
}

func Succeed(code int, c *gin.Context, data interface{}, count int64, msg interface{}) {
	json := &JsonStruct{code, data, count, msg}
	c.JSON(http.StatusOK, json)
}

func Failed(code int, c *gin.Context, msg interface{}) {
	json := &JsonStruct{Code: code, Msg: msg}
	c.JSON(http.StatusOK, json)

}
